package com.hzy.alibaba.service.impl;

import com.hzy.alibaba.dao.primary.UserDao;
import com.hzy.alibaba.entity.primary.User;
import com.hzy.alibaba.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDao userDao;
    @Override
    public User findUserByUserName(String userName) {

        return userDao.getUserByUserName(userName);
    }

    @Override
    public void save(User user) {
        userDao.save(user);
    }

    @Override
    public User selectByKey(Long id) {
        return userDao.findById(id).get();
    }

    @Override
    public Page<User> findAll() {
        return userDao.findAll(PageRequest.of(0, 10));
    }
}


